package com.one.utils;

import org.springframework.stereotype.Component;
import sun.security.ec.SunEC;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;

/**
 * Create on 2022-01-14
 * <p>
 * Author: LiangWei
 * <p>
 * Description:
 **/
@Component
public class SignUtils {
    /**
     * 处理时间格式
     */
    public static String formatDate(LocalDate date){
        return formatDate(date,"yyyyMM");
    }
    public static String formatDate(LocalDate date,String pattern){
        return date.format(DateTimeFormatter.ofPattern(pattern));
    }

    /**
     *@author : LiangWei
     *@date : 2022-01-14 16:39
     *@return :
     *@description : 获取当前用户的签到key（根据用户ID和日期）
     */
    public String getUserSignKey(Integer userId,LocalDate date) {
        return String.format("user:sign:%d:%s",userId,formatDate(date));
    }
}
